<template>
	<div class="order_list table-theme">
		<head-title title="订单--订单列表"></head-title>
		<el-card>
			<div class="type-view">
				<tabs-view :list="classifyList" :tabsIndex="type" @roleType="roleType"></tabs-view>
				<el-select v-model="store_client_type" placeholder="请选择类型" @change="clientType" v-if="admin_type == 1">
					<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
				</el-select>
				<!-- <select-view
				style="margin-left:10px"
					:option-list="typeList"
					:value="platform_id"
					placeholder="类型"
					type="platformId"
					@value="setSelectValue"
				>
					</select-view> -->
			</div>
			<div class="type-view-line"></div>
			<div class="data-filtering-view">
				<div class="data-filtering-left">
					<p style="line-height: 40px;">请选择</p>
					<div class="select-view">
						<el-date-picker @change="selectTime" v-model="selectModel.time" type="daterange" align="right" range-separator="至"
						 start-placeholder="开始日期" end-placeholder="结束日期" :picker-options="pickerOptions" value-format="yyyy-MM-dd"></el-date-picker>
					</div>
					<div class="select-view" v-if="type==1">
						<el-select v-model="waite_status" value-key="" placeholder="确认类型筛选" clearable filterable @change="init(1)">
							<el-option label="待平台确认" :value="2"></el-option>
							<el-option label="待工厂确认" :value="3"></el-option>
						</el-select>
					</div>
					<div class="select-view">
						<el-select v-model="produce_status" value-key="" placeholder="生产状态筛选" clearable filterable @change="init(1)">
							<el-option label="生产中" :value="0"></el-option>
							<el-option label="部分完成" :value="1"></el-option>
							<el-option label="生产完成" :value="2"></el-option>
						</el-select>
					</div>
					<div class="select-view">
						<el-select v-model="notice_status" value-key="" placeholder="通知状态筛选" clearable filterable @change="init(1)">
							<el-option label="未通知发货" :value="0"></el-option>
							<el-option label="部分通知发货" :value="1"></el-option>
							<el-option label="已通知发货" :value="2"></el-option>
						</el-select>
					</div>
				</div>

				<div class="data-filtering-right">
					<refresh-button @refresh="refreshPage"></refresh-button>
					<search-view :option="selectList" @value="goSearch" @clear="refreshPage"></search-view>
					<div class="add" style="margin-top: 5px;margin-right: 10px;">
						<el-button type="primary" size="small" @click="offlineExport" v-if="admin_type == 1">线下导出</el-button>
					</div>
				</div>
			</div>
			<p class="data-number">共{{ total }}条数据</p>
			<el-table :data="orderList" stripe>
				<el-table-column label="序号" align="center" prop="order_id" width="50" fixed="left"></el-table-column>
				<el-table-column label="订单号" align="center" prop="" width="80" fixed="left">
					<template slot-scope="scope">
						<p style="cursor: pointer;" v-clipboard:copy="scope.row.order_sn" v-clipboard:success="onCopy">{{ scope.row.order_sn }}</p>
					</template>
				</el-table-column>
				<el-table-column label="收货人" align="center" prop="address_id.consignee"></el-table-column>
				<el-table-column label="电话" align="center" prop="address_id.mobile"></el-table-column>
				<el-table-column label="签约人员" align="center" prop="introduce_user" width="70"></el-table-column>
				<el-table-column label="运营人员" align="center" prop="follow_user" width="70"></el-table-column>
				<el-table-column label="合同简称" align="center" prop="abbreviation"></el-table-column>
				<el-table-column label="金额" align="center" min-width="120">
					<template slot-scope="scope">
						{{ scope.row.order_amount }}元
					</template>
				</el-table-column>
				<el-table-column label="佣金额" align="center" min-width="120">
					<template slot-scope="scope">
						{{ scope.row.platform_commission }}元
					</template>
				</el-table-column>
				<el-table-column label="手续费" align="center" min-width="120">
					<template slot-scope="scope">
						{{ scope.row.pay_charge }}元
					</template>
				</el-table-column>
				<el-table-column label="已付金额" align="center" min-width="120">
					<template slot-scope="scope">
						{{ scope.row.paid_amount }}元
					</template>
				</el-table-column>
				<el-table-column label="未付金额" align="center" min-width="120">
					<template slot-scope="scope">
						{{ scope.row.unpaid_amount }}元
					</template>
				</el-table-column>
				<el-table-column label="商家" align="center" prop="">
					<template slot-scope="scope">
						<el-tooltip :content="scope.row.store_name" placement="bottom">
							<p class="two-lines">{{ scope.row.store_name }}</p>
						</el-tooltip>
					</template>
				</el-table-column>
				<el-table-column label="所属公司" align="center" prop="filiale_name"></el-table-column>
				<el-table-column label="时间" align="center" prop="add_time" min-width="165"></el-table-column>
				<el-table-column label="店铺等级" align="center">
					<template slot-scope="scope">
						<i class="el-icon-medal" v-if="scope.row.level != 0 && scope.row.level < 5" :class="filterLevelColor(scope.row.level)">
							<span>{{scope.row.level | filterLevel}}</span>
						</i>
						<el-image v-else-if="scope.row.level == 5" style="width:38px;height:24px" :src="require('../../assets/image/interior.png')" fit="cover"></el-image>
						<el-image v-else-if="scope.row.level == 6" style="width:38px;height:24px" :src="require('../../assets/image/new.png')" fit="cover"></el-image>
						<span v-else-if="scope.row.level == 7">定制</span>
						<span v-else-if="scope.row.level == 0">未设置</span>
					</template>
				</el-table-column>
				<el-table-column label="平台备注" align="center" prop="" width="80" v-if="admin_type == 1">
					<template slot-scope="scope">
						<el-tooltip content="点击查看详细备注" placement="bottom">
							<p class="two-lines" @click="seeRemark(scope.row.platform_remark)">{{ scope.row.platform_remark }}</p>
						</el-tooltip>
					</template>
				</el-table-column>
				<el-table-column label="商家备注" align="center" prop="" width="80">
					<template slot-scope="scope">
						<el-tooltip content="点击查看详情备注" placement="bottom">
							<p class="two-lines" @click="seeRemark(scope.row.remark)">{{ scope.row.remark }}</p>
						</el-tooltip>
					</template>
				</el-table-column>
				<el-table-column label="地址ID" align="center" prop="" width="80">
					<template slot-scope="scope">
						<el-tooltip content="点击修改送货地址" placement="bottom">
							<p style="cursor: pointer;" @click="modifyAddress(scope.row.address_id, scope.row.order_id)">{{ scope.row.address_id.address_id }}</p>
						</el-tooltip>
					</template>
				</el-table-column>
				<el-table-column label="发货时间" align="center" prop="express_time" min-width="110"></el-table-column>
				<el-table-column label="发货图片" align="center" width="80" v-if="admin_type == 1">
					<template slot-scope="scope">
						<el-image v-if="scope.row.express_img != null && scope.row.express_img != ''" :src="scope.row.express_img[0]"
						 :preview-src-list="scope.row.express_img" style="width: 50px; height: 50px; vertical-align: top;"></el-image>
					</template>
				</el-table-column>
				<!-- <el-table-column label="厂家物流" align="center" prop="factory_direction"></el-table-column> -->
				<el-table-column label="支付方式" align="center" prop="pay_id"></el-table-column>
				<el-table-column label="支付类型" align="center" prop="settlement_type" min-width="120"></el-table-column>
				<el-table-column label="生产状态" align="center" width="120">
					<template slot-scope="scope">
						<el-tag type="danger" v-if="scope.row.produce_status == 0">{{ scope.row.produce_status_name }}</el-tag>
						<el-tag type="primary" v-if="scope.row.produce_status == 1">{{ scope.row.produce_status_name }}</el-tag>
						<el-tag type="success" v-if="scope.row.produce_status == 2">{{ scope.row.produce_status_name }}</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="订单类型" align="center" width="120" v-if="admin_type == 1">
					<template slot-scope="scope">
						<el-tag type="danger" v-if="scope.row.store_client_type == 1">总部订单</el-tag>
						<el-tag type="warning" v-if="scope.row.store_client_type == 2">商家系统订单</el-tag>
					</template>
				</el-table-column>
				<el-table-column label="平台类型" align="center" prop="platform_type"></el-table-column>
				<el-table-column label="平台支付状态" align="center" width="70">
					<template slot-scope="scope">
						<p style="font-weight: bold;color: #dc3545;">{{ scope.row.status_name }}</p>
					</template>
				</el-table-column>
				<el-table-column label="商家支付状态" align="center" v-if="admin_type == 1" width="70">
					<template slot-scope="scope">
						<p style="font-weight: bold;color: #e6a23c;" v-if="scope.row.store_client_type == 2">{{ scope.row.b_status_name }}</p>
					</template>
				</el-table-column>
				<el-table-column label="是否入仓" align="center" prop="order_warehouse" width="70"></el-table-column>
				<el-table-column label="信息确认" align="center" prop="waite_status_name"></el-table-column>
				<el-table-column label="操作" align="center" width="180" fixed="right">
					<template slot-scope="scope">
						<div class="operate">
							<el-row :gutter="10">
								<el-col :span="7">
									<el-button class="margin-top6px" type="primary" size="mini" @click="openExportDialog(1, scope.row.order_id, scope.row.order_sn,scope.row)"
									 v-if="admin_type == 1">
										导出
									</el-button>
									<el-button class="margin-top6px" type="primary" size="mini" @click="openExportDialog(2, scope.row.order_id, scope.row.order_sn)"
									 v-if="admin_id == 2 || admin_id == 15">
										导出
									</el-button>
								</el-col>
								<el-col :span="7" v-if="admin_type == 1 && scope.row.waite_status < 3 || admin_id == 4 && scope.row.status_name == '待发货'">
									<el-button class="margin-top6px" type="danger" size="mini" @click="cancelOrder(scope.row.order_sn)">
										取消
									</el-button>
								</el-col>
								<el-col :span="10" v-if="scope.row.order_status == 2 && (admin_id == 1 || admin_id == 4)">
									<el-button class="margin-top6px" type="primary" size="mini" @click="operate(3,scope.row.order_sn)">取消回滚</el-button>
								</el-col>
								<el-col :span="7">
									<el-button class="remarks margin-top6px" type="primary" size="mini" @click="operate(1, scope.row.order_sn, scope.row.platform_remark)"
									 v-if="admin_type == 1">
										备注
									</el-button>
								</el-col>
								<el-col :span="7">
									<el-button class="margin-top6px details" type="primary" size="mini" @click="goOrderDetails(scope.row.order_id)">详情</el-button>
								</el-col>
								<el-col :span="10">
									<el-button type="primary" size="mini" class="confirm margin-top6px" v-if="(admin_id == 1 && scope.row.waite_status == 2) || (admin_id == 13 && scope.row.waite_status == 2)"
									 @click="confirmOrder(1, scope.row.order_sn, scope.row.order_id, scope.row.express_move, scope.row.address_id, scope.row.express_address,scope.row)">
										平台确认
									</el-button>
								</el-col>
								<!-- <el-col :span="10">
									<el-button type="primary" size="mini" v-if="(admin_id < 3 && scope.row.waite_status == 1) || (admin_type == 1 && scope.row.waite_status == 1)"
									 class="b-confirm margin-top6px" @click="confirmOrder(2, scope.row.order_sn, scope.row.order_id, scope.row.express_move, scope.row.address_id, scope.row.express_address)">
										商家确认
									</el-button>
								</el-col> -->
								<el-col :span="10">
									<el-button type="primary" size="mini" v-if="(admin_id == 4 || admin_id == 13) && scope.row.pay_status == 0 && scope.row.shipping_status == 0 && scope.row.order_status == 0"
									 class="confirm margin-top6px" @click="confirmOrder(3, scope.row.order_sn, scope.row.order_id, scope.row.express_move, scope.row.address_id, scope.row.express_address,'财务确认',scope.row.unpaid_amount)">
										财务确认
									</el-button>
								</el-col>
								<el-col :span="10">
									<el-button type="primary" size="mini" v-if="(admin_id == 4 || admin_id == 13) && scope.row.pay_status == 3 && scope.row.shipping_status == 0 && scope.row.order_status == 0"
									 class="confirm margin-top6px" @click="confirmOrder(3, scope.row.order_sn, scope.row.order_id, scope.row.express_move, scope.row.address_id, scope.row.express_address,'尾款确认',scope.row.unpaid_amount)">
										尾款确认
									</el-button>
								</el-col>
								<el-col :span="7">
									<el-button class="margin-top6px" type="primary" size="mini" @click="operate(2, scope.row.order_sn, scope.row.platform_remark, scope.row.order_id,scope.row.self_price)"
									 v-if="(admin_id == 4 || admin_id==8 || admin_id==9 || admin_id==13 ) && scope.row.pay_status == 0">
										类型更改
									</el-button>
								</el-col>
								<el-col :span="10">
									<el-button class="margin-top6px" type="primary" size="mini" @click="deliverConfirm(scope.row.order_sn)" v-if="admin_id == 13 && scope.row.is_deliver == 0 && scope.row.pay_status == 2">
										发货通知
									</el-button>
								</el-col>
								<el-col :span="10">
									<el-button class="margin-top6px" type="primary" size="mini" @click="revocationConfirm(scope.row.order_sn)" v-if="admin_id == 13 && scope.row.is_deliver == 1">
										撤回发货
									</el-button>
								</el-col>
								<el-col :span="10" v-if="admin_id == 8 || admin_id == 12 || admin_id == 1 || admin_id == 10 || admin_id == 9">
									<el-button class="margin-top6px" type="primary" size="mini" @click="onCopyAfter(scope.row.order_id)">售后链接</el-button>
								</el-col>
								<el-col :span="10" v-if="scope.row.order_status==0 && scope.row.shipping_status==1 && scope.row.pay_status==2">
									<el-button class="margin-top6px" type="primary" size="mini" @click="ConfirmReceipt(scope.row.order_id)">确认收货</el-button>
								</el-col>
								<el-col :span="10">
									<el-button class="margin-top6px" type="primary" size="mini" @click="notifyShip(scope.row.order_sn)" v-if="scope.row.waite_status >= 3">通知发货</el-button>
								</el-col>
								<!-- <el-col :span="10" v-if="scope.row.is_frozen==0">
									<el-button class="margin-top6px" type="primary" size="mini" @click="confirmClick(scope.row.order_id)">延长冻结</el-button>
								</el-col> -->
							</el-row>
						</div>
					</template>
				</el-table-column>
			</el-table>
			<div class="pages">
				<el-pagination background layout="prev, pager, next, jumper" :total="total" @current-change="init" :current-page="page"></el-pagination>
			</div>
		</el-card>
		<!-- 通知发货弹框 -->
		<el-dialog title="通知发货" :visible.sync="notifyShipDialog" center :modal-append-to-body="false" width="480px">
			<el-form :model="notifyShipForm" ref="notifyShipForm" label-width="120px">
				<div class="remarks-info">
					<el-form-item label="发货时间:" prop="notice_time">
						<el-date-picker style="width: 100%;" v-model="notifyShipForm.notice_time" type="date" placeholder="选择发货日期" value-format="yyyy-MM-dd"></el-date-picker>
					</el-form-item>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="notifyShipDialog = false">取 消</el-button>
				<el-button type="primary" @click="confirmClick(5, 'notifyShipForm')">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 平台备注弹框 -->
		<el-dialog title="平台备注" :visible.sync="remarksDialog" center :modal-append-to-body="false" width="680px">
			<el-form :model="remarksForm" :rules="remarksFormRules" ref="remarksForm" label-width="120px">
				<div class="remarks-info">
					<el-form-item label="平台备注:" prop="remarks">
						<el-input type="textarea" :rows="6" placeholder="请输入内容" v-model="remarksForm.remarks"></el-input>
					</el-form-item>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="remarksDialog = false">取 消</el-button>
				<el-button type="primary" @click="confirmClick(0, 'remarksForm')">确 定</el-button>
			</span>
		</el-dialog>

		<!-- 平台确认弹框 -->
		<el-dialog title="确认订单" :visible.sync="platformDialog" center :modal-append-to-body="false" :append-to-body="true"
		 width="680px">
			<el-form :model="platForm" :rules="platFormRules" ref="platForm">
				<div class="info-exhibition">
					<el-form-item label="收货地址:" prop="express_move">
						<el-select v-model="platForm.express_move" placeholder="请选择" @change="addressSelect(0)">
							<el-option v-for="item in platformOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="选择指定地:" prop="address_id" v-if="platForm.express_move==1 || platForm.express_move==3">
						<el-select v-model="platForm.address_id" placeholder="请选择" style="width: 80%;" filterable @change="choseAddress" v-if="platForm.express_move==1">
							<el-option v-for="item in storeAddressList" :key="item.address_id" :label="item.company_name" :value="item.address_id"></el-option>
						</el-select>
						<el-select v-model="platForm.address_id" placeholder="请选择" style="width: 80%;" filterable @change="choseAddress" v-if="platForm.express_move==3">
							<el-option v-for="item in platformAddressList" :key="item.address_id" :label="item.company_name" :value="item.address_id"></el-option>
						</el-select>
					</el-form-item>
					<p>联系人：{{ addressInfo.consignee }}</p>
					<p>联系电话：{{ addressInfo.mobile }}</p>
					<p>地址：{{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.district }}{{ addressInfo.address }}</p>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="platformDialog = false">取 消</el-button>
				<el-button type="primary" @click="confirmClick(2, 'platForm')">确 定</el-button>
			</span>
		</el-dialog>

		<!-- 商家确认弹框 -->
		<el-dialog title="确认订单" :visible.sync="storeDialog" center :modal-append-to-body="false" width="680px">
			<el-form :model="storeForm" :rules="storeFormRules" ref="storeForm">
				<div class="info-exhibition">
					<el-form-item label="收货地址:" prop="express_move">
						<el-select v-model="storeForm.express_move" placeholder="请选择" @change="addressSelect(1)">
							<el-option v-for="item in storeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
					<p>联系人：{{ addressInfo.consignee }}</p>
					<p>联系电话：{{ addressInfo.mobile }}</p>
					<p>地址：{{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.district }}{{ addressInfo.address }}</p>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="storeDialog = false">取 消</el-button>
				<el-button type="primary" @click="confirmClick(3, 'storeForm')">确 定</el-button>
			</span>
		</el-dialog>

		<!-- 财务确认弹框 -->
		<el-dialog :title="financeDialogTitle" :visible.sync="financeDialog" center :modal-append-to-body="false" width="680px">
			<el-form :model="financeForm" :rules="financeFormRules" ref="financeForm" label-width="100px">
				<div class="remarks-info">
					<el-form-item label="应付金额:">{{ financeFormPrice }}元</el-form-item>
					<el-form-item label="实付金额:" prop="real_amount">
						<el-input placeholder="请输入实付金额" v-model="financeForm.real_amount"></el-input>
					</el-form-item>
					<el-form-item label="支付凭证:" prop="pay_voucher">
						<div class="upload-box" style="padding-left: 0;">
							<div class="goods-img-upload">
								<div class="goods-img-upload-btns" v-if="!financeForm.pay_voucher.length">
									<el-upload ref="upload" action="fakeaction"
										:show-file-list="false" :http-request="function (res) { return upload(res); }" multiple
										accept="image/*"> <el-button type="primary" size="small">上传图片</el-button>
									</el-upload>
								</div>
								<div class="goods-img-upload-imgs">
									<el-image v-if="!financeForm.pay_voucher.length">
										<div slot="error"></div>
									</el-image>
									<div v-for="(data, index) in financeForm.pay_voucher" :key="index" class="vice_big_box" v-else>
										<i class="el-icon-error" @click="delChangeVoucher(index)"></i>
										<el-image :preview-src-list="financeForm.pay_voucher" :src="data" fit="contain"></el-image>
									</div>
								</div>
							</div>
						</div>
					</el-form-item>
					<el-form-item label="备注:" prop="platform_remark">
						<el-input type="textarea" :rows="6" placeholder="请输入内容" v-model="financeForm.platform_remark"></el-input>
					</el-form-item>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="financeDialog = false">取 消</el-button>
				<el-button type="primary" @click="confirmClick(1, 'financeForm')">确 定</el-button>
			</span>
		</el-dialog>

		<!-- 导出弹框 -->
		<el-dialog title="导出订单" :visible.sync="exportDialog" center :modal-append-to-body="false" width="680px">
			<el-table :data="GetFactoryList" stripe style="margin-bottom: 10px;" ref="exportTable">
				<el-table-column label="工厂编号" align="center" prop="factory_sn"></el-table-column>
				<el-table-column label="工厂名称" align="center" prop="factory_name"></el-table-column>
				<el-table-column label="操作" align="center" width="250">
					<template slot-scope="scope">
						<div class="operate">
							<el-button type="primary" size="mini" @click="onEditSite(scope.row)" v-if="editSite.waite_status >= 2">修改地址</el-button>
							<el-button type="primary" size="mini" @click="exportExecl(2, scope.row)">下单导出</el-button>
							<el-button type="primary" size="mini" @click="exportExecl(3, scope.row)">财务导出</el-button>
							<el-button type="primary" size="mini" @click="exportExecl(7, scope.row)">发货清单导出</el-button>
						</div>
					</template>
				</el-table-column>
			</el-table>
			<el-button type="primary" size="small" @click="exportExecl(0)">下单导出</el-button>
			<el-button type="primary" size="small" @click="exportExecl(1)">销售清单导出</el-button>
			<el-button type="primary" size="small" @click="exportExecl(6)" v-if="admin_id == 13">发货清单导出</el-button>
		</el-dialog>

		<!-- 导出弹框 -->
		<el-dialog title="导出订单" :visible.sync="storeExportDialog" center :modal-append-to-body="false" width="300px">
			<el-row :gutter="20">
				<el-col :span="12">
					<el-button type="primary" size="small" @click="exportExecl(4)">销售清单导出</el-button>
				</el-col>
				<el-col :span="12">
					<el-button type="primary" size="small" @click="exportExecl(5)">业主清单导出</el-button>
				</el-col>
			</el-row>
		</el-dialog>
		<!-- 更改类型 -->
		<el-dialog title="更改类型" :visible.sync="typeDialog" center :modal-append-to-body="false" width="300px">
			<el-form :model="typeForm" :rules="typeFormRules" ref="typeForm">
				<el-form-item label="价格:" prop="self_price" style="display:flex">
					<el-input placeholder="请输入内容" v-model.number="typeForm.self_price"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="typeDialog = false">取 消</el-button>
				<el-button type="primary" @click="confirmClick(4, 'typeForm')">确 定</el-button>
			</span>
		</el-dialog>
		<!-- 修改导出地址确认 -->
		<el-dialog title="修改地址" :visible.sync="editSiteFormDialog" center :modal-append-to-body="false"
		 width="680px">
			<el-form :model="editSite" ref="editSite">
				<div class="info-exhibition">
					<el-form-item label="收货地址:">
						<el-select v-model="editSite.express_move" placeholder="请选择" @change="addressSelect(0)">
							<el-option v-for="item in platformOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
						</el-select>
					</el-form-item>
					<p>联系人：{{ addressInfo.consignee }}</p>
					<p>联系电话：{{ addressInfo.mobile }}</p>
					<p>地址：{{ addressInfo.province }}{{ addressInfo.city }}{{ addressInfo.district }}{{ addressInfo.address }}</p>
				</div>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="editSiteFormDialog = false">取 消</el-button>
				<el-button type="primary" @click="onUpdateOrderFactoryAddress">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	import changeAddress from '@/components/layer-dialog/change_address.vue';
	import TabsView from '@/components/TabsView'
	import SelectView from "@/components/SelectView";
	export default {
		name: 'order_list',
		components:{
			TabsView,
			SelectView
		},
		data() {
			return {
				filiale_id: localStorage.getItem('filiale_id'),
				options: [{
						value: '1',
						label: '总部订单'
					},
					{
						value: '2',
						label: '商家系统订单'
					}
				],
				store_client_type: '',
				GetFactoryList: [], // 平台订单查询工厂
				order_id: '',
				addressInfo: {
					consignee: '',
					mobile: '',
					province: '',
					city: '',
					district: '',
					address: '',
				}, // 地址信息
				customerAddress: '', // 客户地址信息
				platformWarehouse: '', // 平台仓库地址信息
				merchantWarehouse: '', // 商家仓库地址信息
				admin_type: localStorage.getItem('admin_type'),
				admin_id: localStorage.getItem('admin_id'), // admin_id  1是总号，2是商家，3是厂家，4财务，5签约，6采购，7仓管 8运营 9设计 10售后
				order_sn: '', // 订单号
				export: {
					order_id: '',
					order_sn: ''
				},
				exportDialog: false, // 平台导出弹框
				storeExportDialog: false, // 商家导出弹框
				remarksDialog: false, // 平台备注弹框
				platformDialog: false, // 平台确认弹框
				storeDialog: false, // 商家确认弹框
				financeDialog: false, // 财务确认弹框
				financeDialogTitle: '财务确认',
				typeDialog:false,//类型更改
				financeFormPrice: 0,
				financeForm: {
					real_amount: '',
					pay_voucher: [],
					platform_remark: ''
				},
				remarksForm: {
					remarks: ''
				},
				factoryForm: {
					complete_time: ''
				},
				platformAddressList: [],
				platForm: {
					express_move: 3,
					address_id: ''
				},
				storeForm: {
					express_move: 1
				},
				financeFormRules: {
					pay_voucher: [{
						type: 'array',
						required: true,
						message: '请上传支付凭证'
					}],
					real_amount: [{
						required: true,
						message: '请输入实付金额'
					}],
					platform_remark: [{
						required: true,
						message: '请输入备注'
					}]
				},
				remarksFormRules: {
					remarks: [{
						required: true,
						message: '请输入平台备注'
					}]
				},
				factoryFormRules: {
					complete_time: [{
						required: true,
						message: '请选择日期'
					}]
				},
				platFormRules: {
					express_move: [{
						required: true,
						message: '请选择地址'
					}],
					address_id: [{
						required: true,
						message: '请选择指定地'
					}],
				},
				storeFormRules: {
					express_move: [{
						required: true,
						message: '请选择地址'
					}]
				},
				platformOptions: [
					{
						value: 1,
						label: '客户物流'
					},
					{
						value: 2,
						label: '客户地址'
					},
					{
						value: 3,
						label: '平台指定'
					}
				],
				storeOptions: [{
						value: 1,
						label: '客户地址'
					},
					{
						value: 2,
						label: '商家仓库'
					}
				],
				selectContent: '', // 分类搜索平输入框的值
				selectText: '', // 搜索框提示语
				classSelect: 1, // 判断 是 哪种类型的搜索 1订单编号 2收货人 3店铺 4运营人员编号
				orderList: [], // 订单列表
				total: 0,
				type: 0,
				page: 0,
				classifyList: [ '全部', '待确认','未支付','待付尾款','已支付','待发货','部分发货','待收货','已完成','已取消' ],
				selectModel: {
					time: '' // 时间
				},
				selectList: [{
						value: 0,
						label: '订单号'
					},
					{
						value: 1,
						label: '收货人'
					},
					{
						value: 2,
						label: '店铺名称'
					},
					{
						value: 3,
						label: '运营人员编号'
					},
					{
						value: 4,
						label: '订单id'
					},
					{
						value:5,
						label:"手机号码"
					},
					{
						value:6,
						label:"店铺id"
					},
					{
						value:7,
						label:'省份'
					},
					{
						value: 8,
						label: '商品编号'
					}
				],
				pickerOptions: {
					disabledDate(time) {
						return time.getTime() > Date.now();
					},
					shortcuts: [{
							text: '最近一周',
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
								picker.$emit('pick', [start, end]);
							}
						},
						{
							text: '最近一个月',
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
								picker.$emit('pick', [start, end]);
							}
						},
						{
							text: '最近三个月',
							onClick(picker) {
								const end = new Date();
								const start = new Date();
								start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
								picker.$emit('pick', [start, end]);
							}
						}
					]
				},
				exportParameter: {
					order_status: '',
					shipping_status: '',
					pay_status: '',
					order_sn: '',
					accept_name: '',
					store_name: '',
					order_id: ''
				},
				typeForm:{
					order_id:'',
					self_price:0
				},
				typeFormRules:{
					self_price:[{
						required:true,
						message:'请输入价格'
					}]
				},
				editSite:{
					order_sn:'',
					factory_sn:'',
					express_move:0,
					waite_status:0
				},
				editSiteFormDialog:false,
				typeList: [
					{
						value: '',
						label: '全部平台'
					},
					{
						value: 1,
						label: '家具大师平台'
					},
					{
						value:2,
						label:'我家更美平台'
					},
					{
						value:3,
						label:'天华平台'
					}
				],
				storeAddressList: [],
				platform_id:'',
				waite_status: '',
				logistics_list: '',
				produce_status: '',
				notifyShipDialog: false,
				notifyShipForm: {
					notice_time:'',
					order_sn:'',
				},
				notice_status: ''
			}
		},
		watch: {
			financeDialog(n,o){
				if(!n){
					this.financeForm = this.$options.data().financeForm
				}
			},
			notifyShipDialog(n,o){
				if(!n){
					this.notifyShipForm = this.$options.data().notifyShipForm
				}
			},
		},
		methods: {
			notifyShip(order_sn){
				this.notifyShipForm.order_sn = order_sn
				this.notifyShipDialog = true
			},
			choseAddress(){
				if(this.platForm.address_id && (this.platForm.express_move==1 || this.platForm.express_move==3)){
					if(this.platForm.express_move==3){
						this.addressInfo = this.platformAddressList.find(item => item.address_id = this.platForm.address_id)
					}else{
						this.addressInfo = this.storeAddressList.find(item => item.address_id = this.platForm.address_id)
					}
				}else{
					this.addressInfo = this.$options.data().addressInfo
				}
			},
			delChangeVoucher(index){
				this.financeForm.pay_voucher.splice(index,1)
			},
			upload(params) {
				if (this.financeForm.pay_voucher.length >= 1) {
					return this.$message.error('最多上传1张');
				}
				const file = params.file,
					isJPGPNG = file.type === 'image/jpeg' || file.type === 'image/png',
					isLt3MB = file.size / 1024 <= 3024;
				if (!isJPGPNG) {
					this.$layer.msg('只能上传图片格式png、jpg!');
					return;
				}
				if (!isLt3MB) {
					this.$layer.msg('图片不能大于3M');
					return;
				}

				let img = new FormData();
				img.append('file[]', file);

				this.$http(this.$ApiList.publicUpload, img).then(res => {
					this.financeForm.pay_voucher.push(res.datas[0])
				});
			},
			// 确认收货
			ConfirmReceipt(order_id){
				this.$confirm('确认收货后资金将进入解冻倒计时流程', '温馨提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				})
				.then(() => {
					this.$http(this.$ApiList.OrderConfirm, {order_id}).then(res => {
						if (res.code == 200) {
							this.$message({
								message: '确认收货成功',
								type: 'success'
							});
							this.init();
						}
					});
				})
				.catch(() => {});
			},
			// 初始化列表
			init(e) {
				this.page = e;
				let data = {
					page: e - 1 ? e - 1 : 0,
					limit: 10,
					platform_id:this.platform_id
				};

				if (this.store_client_type != "") {
					data.store_client_type = this.store_client_type
				}

				if (localStorage.getItem('admin_type') != 1) {
					data.store_id = localStorage.getItem('store_id');
					data.goods_store_id = localStorage.getItem('store_id');
				}
				
				// if (this.filiale_id != 1) {
				// 	delete data.store_id
				// }
				
				// 选择了时间
				if (this.selectModel.time != '' && this.selectModel.time != null) {
					data.start_time = this.selectModel.time[0];
					data.end_time = this.selectModel.time[1];
				}

				// 1订单编号 2收货人 3店铺 4运营人员编号
				if (this.classSelect == 0) {
					data.order_sn = this.selectContent;
					this.exportParameter.order_sn = this.selectContent;
				} else if (this.classSelect == 1) {
					data.accept_name = this.selectContent;
					this.exportParameter.accept_name = this.selectContent;
				} else if (this.classSelect == 2) {
					data.store_name = this.selectContent;
					this.exportParameter.store_name = this.selectContent;
				} else if (this.classSelect == 3) {
					data.follow_user = this.selectContent;
				} else if (this.classSelect == 4) {
					data.order_id = this.selectContent;
					this.exportParameter.order_id = this.selectContent;
				}else if(this.classSelect == 5){
					data.mobile_phone = this.selectContent;
				}else if(this.classSelect == 6){
					data.store_id = this.selectContent;
				}else if(this.classSelect == 7){
					data.province = this.selectContent;
				}else if(this.classSelect == 8){
					data.goods_sn = this.selectContent;
				}

				// 0全部 1待确认 2未支付 3待付尾款 4已支付 5待发货 6部分发货 7待收货 8已完成 9已取消
				if (this.type == 4) {
					data.asc = 1;
					data.order_by = 'add_time';
				} else if (this.type == 5) {
					data.asc = 2;
					data.order_by = 'express_time';
				} else {
					delete data.asc;
					delete data.order_by;
				}
				

				switch (this.type) {
					case 0:
						delete data.order_status;
						delete data.shipping_status;
						delete data.pay_status;
						delete data.waite_status;
						this.exportParameter.order_status = '';
						this.exportParameter.shipping_status = '';
						this.exportParameter.pay_status = '';
						break;
					case 1:
						data.order_status = 0;
						data.shipping_status = 0;
						data.pay_status = 2;
						// data.waite_status = '1,2,3';
						data.waite_status = this.waite_status
						this.exportParameter.order_status = 0;
						this.exportParameter.shipping_status = 0;
						this.exportParameter.pay_status = 2;
						break;
					case 2:
						data.order_status = 0;
						data.shipping_status = 0;

						this.exportParameter.order_status = 0;
						this.exportParameter.shipping_status = 0;
						this.exportParameter.pay_status = 0;
						if (this.store_client_type == 2) {
							data.store_pay_status = 0
						} else {
							data.pay_status = 0;
						}
						break;
					case 3:
						data.order_status = 0;
						data.shipping_status = 0;
						data.pay_status = 3;
						this.exportParameter.order_status = 0;
						this.exportParameter.shipping_status = 0;
						this.exportParameter.pay_status = 3;
						break
					case 4:
						data.order_status = '0,1';
						data.shipping_status = '';
						data.waite_status = '1,2,3,5';
						this.exportParameter.order_status = '0,1';
						this.exportParameter.shipping_status = '0,1,2';
						this.exportParameter.pay_status = 2;
						if (this.store_client_type == 2) {
							data.store_pay_status = 2
						} else {
							data.pay_status = 2;
						}
						break;
					case 5:
						data.order_status = 0;
						data.shipping_status = 0;
						data.pay_status = 2;
						this.exportParameter.order_status = 0;
						this.exportParameter.shipping_status = 0;
						this.exportParameter.pay_status = 2;
						break;
					case 6:
						data.order_status = 0;
						data.shipping_status = 4;
						data.pay_status = 2;
						this.exportParameter.order_status = 0;
						this.exportParameter.shipping_status = 4;
						this.exportParameter.pay_status = 2;
						break;
					case 7:
						data.order_status = 0;
						data.shipping_status = 1;
						data.pay_status = 2;
						this.exportParameter.order_status = 0;
						this.exportParameter.shipping_status = 1;
						this.exportParameter.pay_status = 2;
						break;
					case 8:
						data.order_status = 1;
						data.shipping_status = 2;
						data.pay_status = 2;
						this.exportParameter.order_status = 1;
						this.exportParameter.shipping_status = 2;
						this.exportParameter.pay_status = 2;
						break;
					case 9:
						delete data.shipping_status;
						delete data.pay_status;
						delete data.waite_status;
						data.order_status = 2;
						this.exportParameter.order_status = 2;
						this.exportParameter.shipping_status = '';
						this.exportParameter.pay_status = '';
						break;
				}

				if(this.produce_status!==''){
					data.produce_status = this.produce_status
				}

				data.notice_status = this.notice_status

				this.$http(this.$ApiList.OrderList, data).then(res => {
					this.orderList = [];
					res.datas.data.forEach(item => {
						if (item.express_move == 1) {
							item.direction = '用户地址';
							item.direction_detailed = item.address_id.city + item.address_id.district + item.address_id.address;
						} else if (item.express_move == 2) {
							item.direction = '商家仓库';
							item.direction_detailed = item.express_address.city + item.express_address.district + item.express_address.address;
						} else if (item.express_move == 3) {
							item.direction = '平台仓库';
							item.direction_detailed = this.platformWarehouse;
						}

						let factory = ['', '发货到客户', '发货到商家', '平台仓库'];
						item.factory_direction = factory[item.factory_move];
						let waite = ['', '待商家确认', '待平台确认', '待工厂确认', '待财务确认', '已确认'];
						let b_status_name = ['未付款', '', '已付款'];
						item.b_status_name = b_status_name[item.store_pay_status];
						if (item.pay_status == 2) {
							item.waite_text = waite[item.waite_status];
						} else {
							item.waite_text = '未付款';
						}

						this.orderList.push(item);
					})

					this.total = res.datas.count;
					console.log(this.addressInfo)
				});
			},
			goSearch(classSelect, selectContent) {
				console.log(classSelect, selectContent)
				this.classSelect = classSelect;
				this.selectContent = selectContent;
				this.init();
			},
			roleType(index) {
				this.selectContent = '';
				this.type = index;
				this.init();
			},
			// 刷新
			refreshPage() {
				this.type = 0;
				this.selectText = '';
				this.classSelect = 1;
				this.selectContent = '';
				this.selectModel.time = '';
				this.page = 1;
				this.store_client_type = '';
				this.init();
			},
			selectTime() {
				this.init();
			},
			// 操作
			operate(type, order_sn, platform_remark, order_id,self_price) {
				switch (type) {
					case 1:
						this.remarksForm.remarks = platform_remark;
						this.remarksDialog = true; // 平台备注弹框
						this.order_sn = order_sn;
						break;
					case 2:
						this.typeDialog = true;
						this.typeForm.order_id = order_id;
						this.typeForm.self_price = self_price
						break;
					case 3:
						this.$http(this.$ApiList.OrderRollback,{order_sn}).then(res=>{
							this.$message.success(res.datas);
							this.init(this.page);
						})
						break;
				}
			},
			goOrderDetails(id) {
				this.$router.push({
					path: '/order_details',
					query: {
						id: id
					}
				});
			},
			// 取消订单
			cancelOrder(id) {
				let data = {
					order_sn: id
				};
				this.$confirm('确定取消订单吗?', '提示', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						this.$http(this.$ApiList.OrderCancel, data).then(res => {
							if (res.code == 200) {
								this.$message({
									message: '取消成功',
									type: 'success'
								});
								this.init();
							}
						});
					})
					.catch(() => {});
			},
			// 确认按钮 type 1平台确认 2商家确认 3财务确认
			confirmOrder(type, order_sn, order_id, express_move, address_id, express_address,row,unpaid_amount) {
				this.order_id = order_id;
				this.customerAddress = address_id;
				this.logistics_list = row.logistics_list
				if (express_move == 2) {
					this.platformOptions[0].value = 1;
					this.platformOptions[0].label = '商家仓库';
				}

				this.order_sn = order_sn;
				this.order_id = order_id;

				if (type == 1) {
					// 获取商家仓库地址
					let data = {
						order_id: this.order_id
					};
					this.$http(this.$ApiList.StoreAddressList, data).then(res => {
						if (res.code == 200) {
							this.storeAddressList = res.datas;
						}
					});
					this.addressInfo = row.logistics_list;
					this.platForm.express_move = row.logistics_list.logistics_type==1?3:1;
					this.platForm.address_id = row.logistics_list.address_id || ''
					this.platformDialog = true;
					// this.$confirm('请您确认是否确认订单，确认后不可再更改商品指派工厂及定制请认真核对订单详情', '温馨提示', {
					// 	confirmButtonText: '下一步',
					// 	cancelButtonText: '取消',
					// 	type: 'warning'
					// }).then(() => {
					// 	this.platForm.express_move = 3;
					// 	this.platformDialog = true;
					// }).catch(() => {});
				} else if (type == 2) {
					// 获取商家仓库地址
					let data = {
						order_id: this.order_id
					};
					this.$http(this.$ApiList.StoreAddressList, data).then(res => {
						if (res.code == 200) {
							this.merchantWarehouse = res.datas;
						}
					});

					this.storeForm.express_move = 1;
					this.storeDialog = true;
					this.addressInfo = this.customerAddress;
				} else if (type == 3) {
					this.financeFormPrice = unpaid_amount
					this.financeDialogTitle = row
					this.financeDialog = true;
				}
			},
			// 获取平台物流点
			SelectPlatformLogistics(){
				this.$http(this.$ApiList.SelectPlatformLogistics).then(res => {
					this.platformAddressList = res.datas
				})
			},
			// 确认订单地址选择
			addressSelect(type) {
				// type 0 平台确认订单地址选择 1 商家确认订单地址选择
				if (type == 0) {
					this.platForm.address_id = ''
					this.choseAddress()
					if(this.platForm.express_move == 1 || this.platForm.express_move==3){
						this.addressInfo = this.logistics_list
					}else{
						this.addressInfo = this.customerAddress
					}
					// if (this.platForm.express_move == 1 || this.editSite.express_move == 1) {
					// 	if (this.platformOptions[0].label == '商家仓库') {
					// 		// 商家仓库地址
					// 		this.addressInfo = this.merchantWarehouse;
					// 	} else {
					// 		// 客户地址
					// 		this.addressInfo = this.customerAddress;
					// 	}
					// } else if (this.platForm.express_move == 3 || this.editSite.express_move == 3) {
					// 	// 平台仓库地址
					// 	this.addressInfo = this.platformWarehouse;
					// }
				} else {
					if (this.storeForm.express_move == 1) {
						// 客户地址
						this.addressInfo = this.customerAddress;
					} else if (this.storeForm.express_move == 2) {
						if (this.merchantWarehouse == null) {
							this.storeForm.express_move = 1;
							this.$message({
								showClose: true,
								message: '该商家没有商家仓库地址',
								type: 'warning'
							});
							if (this.admin_id == 2) {
								this.$router.push({
									path: '/storehouse'
								});
							}
						} else {
							// 商家仓库地址
							this.addressInfo = this.merchantWarehouse;
						}
					}
				}
			},
			//提交
			confirmClick(type, formName) {
				// type 0 平台备注 1财务确认 2平台确认 3商家确认 4修改地址
				this.$refs[formName].validate(valid => {
					if (valid) {
						if (type == 0) {
							let data = {
								order_sn: this.order_sn,
								platform_remark: this.remarksForm.remarks
							};
							console.log(data);
							this.$http(this.$ApiList.UpOrderRemark, data).then(res => {
								if (res.code == 200) {
									this.$layer.msg('备注成功');
									this.remarksDialog = false;
									this.init();
								}
							});
						} else if (type == 1) {
							this.financeForm.order_id = this.order_id;
							let data = {
								order_id: this.order_id,
								platform_remark: this.financeForm.platform_remark,
								real_amount: this.financeForm.real_amount,
								pay_voucher: this.financeForm.pay_voucher.join(','),
							}
							if(this.financeDialogTitle==='财务确认'){
								this.$http(this.$ApiList.OrderPay, data).then(res => {
									if (res.code == 200) {
										this.$layer.msg('确认成功');
										this.financeDialog = false;
										this.init();
									}
								});
							}else{
								this.$http(this.$ApiList.TailOrderPay, data).then(res => {
									if (res.code == 200) {
										this.$layer.msg('确认成功');
										this.financeDialog = false;
										this.init();
									}
								});
							}
							//console.log(this.financeForm)
						} else if (type == 2) {
							this.platForm.order_sn = this.order_sn;
							console.log(this.platForm)
							console.log(this.addressInfo)
							debugger;
							//return
							this.$http(this.$ApiList.OrderPlatformConfirm, this.platForm).then(res => {
								this.$layer.msg('确认成功');
								this.platformDialog = false;
								this.init();
							});
						} else if (type == 3) {
							this.storeForm.order_sn = this.order_sn;
							this.$http(this.$ApiList.OrderStoreConfirm, this.storeForm).then(res => {
								this.$layer.msg('确认成功');
								this.storeDialog = false;
								this.init();
							});
						} else if (type == 4) {
							this.$http(this.$ApiList.OrderChange, this.typeForm).then(res => {
								this.$layer.msg('更改成功');
								this.refreshPage();
								this.typeDialog = false;
							});
						}else if(type == 5){
							this.$http(this.$ApiList.NoticeSend, this.notifyShipForm).then(res => {
								this.$layer.msg('通知成功');
								this.refreshPage();
								this.notifyShipDialog = false;
							});
						}
					} else {
						this.$layer.msg('请填写完整信息后提交');
					}
				});
			},
			// 获取仓库地址
			getWarehouse() {
				this.$http(this.$ApiList.platformAddressList).then(res => {
					this.platformWarehouse = res.datas;
					this.addressInfo = res.datas;
				});
			},
			// 修改地址
			modifyAddress(userAddress, orderId) {
				this.order_id = orderId;
				let modifyAddressForm = {
					accept_name: userAddress.consignee,
					mobile_phone: userAddress.mobile,
					province: userAddress.province,
					city: userAddress.city,
					area: userAddress.district,
					address: userAddress.address,
					order_id: orderId,
				}
				this.$layer.iframe({
					title: '修改地址',
					maxmin: true,
					area: ['50%', '60%'],
					content: {
						content: changeAddress, //传递的组件对象
						parent: this, //当前的vue对象
						data: {
							info: modifyAddressForm
						} //props
					}
				});
			},
			addressDetailed(direction) {
				this.$alert(direction, '详细地址', {
					confirmButtonText: '确定',
					callback: action => {}
				});
			},
			seeRemark(remark) {
				this.$alert(remark, '详细备注', {
					confirmButtonText: '确定',
					callback: action => {}
				});
			},
			openExportDialog(type, order_id, order_sn,row) {
				this.export.order_id = order_id;
				this.export.order_sn = order_sn;
				if (type == 1) {
					let data = {
						order_id: order_id
					};
					this.$http(this.$ApiList.GetFactory, data).then(res => {
						this.GetFactoryList = res.datas;
						this.$nextTick(() => {
							this.$refs.exportTable.doLayout();
						});
					});
					this.exportDialog = true;
					this.customerAddress = row.address_id;
					this.merchantWarehouse = row.express_address;
					this.addressInfo = this.platformWarehouse;
					this.editSite.order_sn = order_sn;
					this.editSite.waite_status = row.waite_status
					this.editSite.express_move = row.express_move;
				} else if (type == 2) {
					this.storeExportDialog = true;
				}
			},
			// 导出表格
			exportExecl(type,row) {
				// type = 4,factory_sn 就是 order_sn
				// type 0下单导出 1 销售清单导出 2 工厂下单导出 3 工厂财务导出 4 商家销售清单导出 5 商家业主导出
				let url = '';
				if (type == 0) {
					url = `${this.$domain}furniture/Adminexcel/GetAllData?order_id=` + this.export.order_id +
						'&order_sn=' + this.export.order_sn;
				} else if (type == 1) {
					url = `${this.$domain}furniture/Adminexcel/SaleDataExcel?order_id=` + this.export.order_id;
				} else if (type == 2) {
					if(row.is_transfer == 1){
						url = `${this.$domain}furniture/Adminexcel/FactoryTransferGetData?order_id=` +
						this.export.order_id +
						'&order_sn=' +
						this.export.order_sn +
						'&factory_id=' +
						row.factory_id +
						'&type=1'
					}else{
						url = `${this.$domain}furniture/Adminexcel/FactoryGetData?order_id=` +
						this.export.order_id +
						'&order_sn=' +
						this.export.order_sn +
						'&factory_sn=' +
						row.factory_sn +
						'&factory_style_sn=' +
						row.factory_style_sn +
						'&type=1'
					}		
				} else if (type == 3) {
					if(row.is_transfer == 1){
						url = `${this.$domain}furniture/Adminexcel/FactoryTransferGetData?order_id=` +
						this.export.order_id +
						'&order_sn=' +
						this.export.order_sn +
						'&factory_id=' +
						row.factory_id +
						'&type=2'
					}else{
						url = `${this.$domain}furniture/Adminexcel/FactoryGetData?order_id=` +
						this.export.order_id +
						'&order_sn=' +
						this.export.order_sn +
						'&factory_sn=' +
						row.factory_sn +
						'&factory_style_sn=' +
						row.factory_style_sn +
						'&type=2'
					}
				} else if (type == 4) {
					url = `${this.$domain}furniture/Adminexcel/SaleDataExcel?order_id=` + this.export.order_id;
					//url = `${this.$domain}furniture/Adminexcel/StoreGetData?order_id=` + order_id + '&order_sn=' + factory_sn;
				} else if (type == 5) {
					url = `${this.$domain}furniture/Adminexcel/OwnerDataExcel?order_id=` + this.export.order_id;
				} else if (type == 6) {
					url = `${this.$domain}furniture/Adminexcel/GetAllDeliverData?order_id=` + this.export.order_id  + '&order_sn=' +
					this.export.order_sn;
				}else if(type==7){
					url = `${this.$domain}furniture/Adminexcel/GetFactoryDeliverData?order_id=` + this.export.order_id  + '&factory_sn=' + row.factory_sn;
				}
				window.location.href = url;
			},
			offlineExport() {
				if (this.selectModel.time == '' || this.selectModel.time == null) {
					this.$layer.msg('请选择开始日期和结束日期');
					return;
				}
				let url =
					`${this.$domain}furniture/Adminexcel/GetAllDataExcel?start_time=` +
					this.selectModel.time[0] +
					'&end_time=' +
					this.selectModel.time[1] +
					'&order_status=' +
					this.exportParameter.order_status +
					'&shipping_status=' +
					this.exportParameter.shipping_status +
					'&pay_status=' +
					this.exportParameter.pay_status +
					'&order_sn=' +
					this.exportParameter.order_sn +
					'&accept_name=' +
					this.exportParameter.accept_name +
					'&store_name=' +
					this.exportParameter.store_name +
					'&order_id=' +
					this.exportParameter.order_id + 
					'&platform_id=' + 
					this.platform_id;
				window.location.href = url;
			},
			clientType() {
				this.init();
			},
			// 复制成功时的回调函数
			onCopy() {
				this.$message.success('内容已复制到剪切板！');
			},
			deliverConfirm(order_sn) {
				this.$http(this.$ApiList.OrderDeliverConfirm, {
					order_sn: order_sn
				}).then(res => {
					this.$layer.msg(res.datas);
				});
			},
			onCopyAfter(order_id){
				let url = `${this.$domain}web/shop/#/my/my-order/order-details/order-sales-details?id=${order_id}&activity=74785`;
				let oInput = document.createElement("input");
				oInput.value = url;
				document.body.appendChild(oInput);
				oInput.select(); // 选择对象;
				document.execCommand("Copy"); // 执行浏览器复制命令
				this.$message({
					message: "复制成功,请进行粘贴",
					type: "success",
					duration: 3000,
				});
				oInput.remove();
			},
			filterLevelColor(data){
				switch (data) {
					case 1:
						return 'oneLevel';
						break;
					case 2:
						return 'twoLevel';
						break;
					case 3:
						return 'threeLevel';
						break;
					case 4:
						return 'fourLevel';
						break;
					default:
						break;
				}
			},
			// 撤销发货
			revocationConfirm(order_sn){
				this.$confirm('此操作将撤回发货, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				})
				.then(() => {
					this.$http(this.$ApiList.OrderDeliverConfirmRevoke,{order_sn}).then(res=>{
						this.$message.success(res.datas);
						this.init(this.page);
					})
				})
				.catch(() => {});
			},
			// 导出修改地址
			onEditSite(row){
				this.editSiteFormDialog = true
				this.editSite.factory_sn = row.factory_sn
				if(this.editSite.express_move == 1){
					this.addressInfo = this.customerAddress;
				}else{
					this.addressInfo = this.platformWarehouse;
				}
			},
			onUpdateOrderFactoryAddress(){
				delete this.editSite.waite_status
				this.$http(this.$ApiList.UpdateOrderFactoryAddress,this.editSite).then(res=>{
					this.$message.success(res.datas);
					this.editSiteFormDialog = false
				})
			},
			setSelectValue(obj){
				const { value } = obj
				this.platform_id = value
				this.init()
			}
		},
		created() {
			this.init();
			this.getWarehouse();
			this.SelectPlatformLogistics()
			if (this.admin_id == 2) {
				this.selectList = [{
					value: 0,
					label: '订单号'
				}];
			}
		},
		filters: { 
			filterLevel(data){
				switch (data) {
					case 1:
						return 'A';
						break;
					case 2:
						return 'B';
						break;
					case 3:
						return 'C';
						break;
					case 4:
						return 'D';
						break;
					default:
						break;
				}
			}
		}
	};
</script>
<style lang="scss">
.vl-notify{
	z-index: 10000;
}
</style>
<style lang="scss" scoped>
	.type-view {
		display: flex;
	}

	.type-view-line {
		margin-top: 20px;
		height: 1px;
		background-color: #e1e1e1;
	}

	.data-filtering-view {
		margin-top: 30px;
		display: flex;
		align-items: center;
	}

	.data-filtering-left,
	.data-filtering-right {
		display: flex;
	}

	.data-filtering-right {
		flex: 1;
		flex-direction: row-reverse;
	}

	.data-filtering-view .select-view {
		margin-left: 10px;
		margin-right: 5px;
	}

	/* 自定义输入框样式 */
	.data-filtering-view .input-with-select .el-input-group__prepend {
		width: 140px;
		background-color: #fff;
	}

	.data-filtering-view .input-with-select .el-input__inner:nth-child(2) {
		width: 170px;
		padding-right: 15px;
	}

	/* 数据筛选 -end*/
	.margin-top6px {
		margin-top: 6px;
	}

	/* 表格内的操作 */
	.order_list .operate p {
		line-height: 24px;
		font-size: 12px;
		text-align: center;
		color: #fff;
		border-radius: 5px;
		cursor: pointer;
	}

	.order_list .operate .remarks {
		background-color: #574b90;
	}

	.order_list .operate .details {
		background-color: #009688;
	}

	.order_list .operate .logistics {
		background-color: #36c3b4;
	}

	.order_list .operate .export {
		background-color: #36c3b4;
	}

	.order_list .operate .confirm {
		background-color: #36c3b4;
	}

	.order_list .operate .b-confirm {
		background-color: #2073f5;
	}

	.order_list .operate .p-confirm {
		background-color: #fe9b26;
	}

	/* 表格内的操作-end */
	.info-exhibition p {
		padding-left: 10px;
		line-height: 30px;
		margin-bottom: 20px;
	}

	.order_list .two-lines {
		cursor: pointer;
		text-overflow: ellipsis;
		/* display: -webkit-box; */
		/* -webkit-line-clamp: 2; */
		/* 可以显示的行数，超出部分用...表示 */
		/* -webkit-box-orient: vertical; */
		overflow: hidden;
		white-space: nowrap;
	}

	.order_list .cell {
		padding: 0 5px !important;
	}
	.el-icon-medal{
		font-size: 40px;
		position: relative;
	}
	.el-icon-medal>span{
		position: absolute;
		bottom: 7px;
		left: 50%;
		font-size: 16px;
		font-weight: 600;
		transform: translateX(-50%);
	}
	.oneLevel{
		color: #e51c23;
	}
	.twoLevel{
		color: #3c8dbc;
	}
	.threeLevel{
		color:#009688;
	}
	.fourLevel{
		color:#141414;
	}
	.upload-box {
	// padding-left: 40px;

	.goods-img-upload {
		display: flex;

		.goods-img-upload-imgs {
			flex: 1;
			align-items: flex-start;

			.el-image {
				width: 140px;
				height: 140px;
				border: solid 1px #e5e5e5;
				margin-left: 25px;
				vertical-align: top;
			}
		}

		.goods-img-upload-imgs-info {
			width: 100%;
			max-width: 660px;
			border: solid 1px #e5e5e5;
			margin-left: 25px;
			min-height: 390px;

			.goods-img-upload-imgs-info-box {
				position: relative;

				.el-icon-error {
					position: absolute;
					font-size: 20px;
					color: #ef3030;
					right: 5px;
					top: 5px;
					z-index: 1;
					background-color: #fff;
					border-radius: 50%;
					cursor: pointer;
				}
			}

			.el-image {
				width: 100%;
				vertical-align: top;
			}
		}

		.vice_big_box {
			position: relative;
			display: inline-block;
			vertical-align: top;
			margin-bottom: 20px;

			.el-icon-error {
				position: absolute;
				font-size: 20px;
				color: #ef3030;
				right: 5px;
				top: 5px;
				z-index: 1;
				background-color: #fff;
				border-radius: 50%;
				cursor: pointer;
			}
		}
	}

	.el-upload__tip {
		width: 80px;
		text-align: center;
	}

	.el-form-item__label {
		float: none;
	}

	.el-form-item__content {
		margin-left: 0 !important;

		.el-button--danger {
			width: 80px;
			background-color: #37c1d6;
			border-color: #37c1d6;
		}
	}
}
</style>
